#include<iostream>
#include<cstdio>
#include<istream>
#include<ostream>
#include<ctime>
#define gencpp
#include"sims.cpp"
using namespace std;
static vector<int>vec[1000];
int main()
{
	const int _Q = 10, _L = 10;
	const int _C = 81;
	//freopen("input.txt","r",stdin);
	ofstream op;
	
		for(int aa = 1; aa <= 500; ++aa){
		cout<<aa<<endl;
		
	op.open("input.txt");
	// n V E
	// n vehicles:
	// each vehicle: motor_power skill_power obstruct_power start_time s t
	// V vertexies
	// id from 1 to V
	// E roads
	// each road: s t quality length (as directed edges)
	static int n, v, e;
	srand(time(0));
	
	/*
	n = 200;
	v = _C;
	e = _C;
	op<<n<<" "<<v<<" "<<e<<endl;
	for(int i = 1; i <= n; ++i)
	{
		int sp = rand() % _C, tp;
		tp = sp;
		if(tp == 0)tp = _C;
		sp += 1;
		op<<(400 + rand()%100)<<" "<<(15 + rand()%10)<<" "<<(5 + rand()%30)<<" "<<(rand()%30)<<" "<<sp<<" "<<tp<<endl;
	}
	for(int i = 1; i <= e; ++i)
	{
		int sp = i, tp = i + 1;
		if(tp == v + 1)tp = 1;
		op<<sp<<" "<<tp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
	}
	*/
	
	
	n = 800;
	v = _C;
	e = 2 * (v + 2);
	op<<n<<" "<<v<<" "<<e<<endl;
	
	int _s1 = v / 3;
	int _s2 = _s1 + _s1 / 2;
	int _s3 = _s1 - _s1 / 2;
	vector<int>_vec;
	for(int i = 1; i <= v; ++i)
	{
		_vec.push_back(i);
	}
	random_shuffle(_vec.begin(), _vec.end());
	for(int i = 1; i <= n; ++i)
	{
		int sp = (rand() % _C) + 1, tp = (rand() % _C) + 1;
		while(tp == sp)
		{
			tp = (rand() % _C) + 1;
		}
		op<<(400 + rand()%100)<<" "<<(15 + rand()%10)<<" "<<(5 + rand()%30)<<" "<<(rand()%30)<<" "<<sp<<" "<<tp<<endl;
	}
	for(int i = 0; i + 1 < v; ++i)
	{
		int sp = _vec[i], tp = _vec[i + 1];
		op<<sp<<" "<<tp<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
		op<<tp<<" "<<sp<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	}
	op<<_vec[v - 1]<<" "<<_vec[_s1 + _s2]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	op<<_vec[_s1 + _s2]<<" "<<_vec[v - 1]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	
	op<<_vec[_s1]<<" "<<_vec[_s1 + _s2 - 1]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	op<<_vec[_s1 + _s2 - 1]<<" "<<_vec[_s1]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	
	op<<_vec[_s1 - 1]<<" "<<_vec[0]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	op<<_vec[0]<<" "<<_vec[_s1 - 1]<<" "<<(1 + rand()%_Q)<<" "<<(10 + rand()%_L)<<endl;
	
	/*
	n = 1600;
	v = _C;
	e = 2 * (2 * v - 1);
	op<<n<<" "<<v<<" "<<e<<endl;
	
	vector<int>_vec;
	for(int i = 1; i <= v; ++i)
	{
		_vec.push_back(i);
	}
	random_shuffle(_vec.begin(),_vec.end());
	for(int i = 1; i <= n; ++i)
	{
		int sp = (rand() % _C) + 1, tp = (rand() % _C) + 1;
		while(tp == sp)
		{
			tp = (rand() % _C) + 1;
		}
		op<<(400 + rand()%100)<<" "<<(15 + rand()%10)<<" "<<(5 + rand()%30)<<" "<<(rand()%60)<<" "<<sp<<" "<<tp<<endl;
	}
	for(int i = 1; i * 2 < v; ++i)
	{
		int sp = _vec[i - 1], tp = _vec[i * 2 - 1];
		op<<sp<<" "<<tp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
		op<<tp<<" "<<sp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
		tp = _vec[i * 2];
		op<<sp<<" "<<tp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
		op<<tp<<" "<<sp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
	}
	for(int i = 0; i < v; ++i)
	{
		int sp = (rand() % _C) + 1, tp = (rand() % _C) + 1;
		while(tp == sp)
		{
			tp = (rand() % _C) + 1;
		}
		op<<sp<<" "<<tp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
		op<<tp<<" "<<sp<<" "<<(1 + rand()%5)<<" "<<(10 + rand()%5)<<endl;
	}
	*/
	op.close();
	
	
	op.open("out.txt");
	s_main();
	

	op.close();
	for(int i = 0; i < n ; ++i)
	{
		//cout<<i<<endl;
		vec[arriving_times[i].first].push_back(arriving_times[i].second);
	}
	
	
}
	
	for(int i = 0; i < 60; ++i)
	{
		random_shuffle(vec[i].begin(),vec[i].end());
		sort(vec[i].begin(), vec[i].end());
	}
	op.open("out.txt");
	for(int i = 0; i < 1000; ++i)
	{
		//cout<<vec[i].size()<<endl;
		if(vec[i].size() > 0)
		{
			op<<i<<(char)9<<vec[i][vec[i].size()/2]<<endl;
		}
	}
	op.close();
	//system("out.txt");
	/*int res = simulation();
	cout<<res<<endl;
	for(int i = 0; i < n ; ++i)
	{
		op<<arriving_times[i].first<<(char)9<<arriving_times[i].second<<endl;
	}*/
	return 0;
}
